<template>
  <view class="example">
    <view class="title">
      <text>增值服务</text>
    </view>
    <!-- 基础用法，不包含校验规则 -->
    <uni-forms ref="baseForm" :modelValue="model">
      <uni-row>
        <uni-col>
          <uni-forms-item label="选择类型" required name="customerName" label-width="120">
            <uni-data-select v-model="seviceType" :localdata="dataOptions" :clear="false"
                             style="text-align: right"></uni-data-select>
          </uni-forms-item>
        </uni-col>
        <uni-col>
          <uni-forms-item label="金额" required name="money">
            <uni-easyinput v-model="model.money" placeholder="请输入金额" type="number"/>
          </uni-forms-item>
        </uni-col>
      </uni-row>
    </uni-forms>
    <view class="example">
      <my-button align="bottom" @click="submit()">添加</my-button>
    </view>
  </view>
</template>
<script>
import UniForms from "../../uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
import UniRow from "../../uni_modules/uni-row/components/uni-row/uni-row.vue";
import UniCol from "../../uni_modules/uni-row/components/uni-col/uni-col.vue";
import ADataSelect from "../functional/select/a-data-select.vue";
import UniFormsItem from "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";
import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
import UniEasyinput from "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue";
import UniDataSelect from "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue";
import MyButton from "../functional/button/myButton.vue";

export default {
  name: "aSevicePopup",
  components: {MyButton, UniDataSelect, UniEasyinput, UniIcons, UniFormsItem, ADataSelect, UniCol, UniRow, UniForms},
  data() {
    return {
      model: {},
      seviceType: "",
      url: {
        list: "services/noPagelist"
      },
      dataOptions: []
    }
  },
  methods: {
    submit() {
      if (!this.seviceType || this.seviceType.length == 0) {
        uni.showToast({
          title: `请选择类型！`,
          icon: 'none'
        })
        return
      }
      if (!this.model.money || this.model.money.length == 0) {
        uni.showToast({
          title: `请输入金额！`,
          icon: 'none'
        })
        return
      }
      let temp = JSON.parse(this.seviceType)
      this.model.sevicesTitle = temp.sevicesTitle
      this.model.id = temp.id
      this.$emit('submit', this.model);
    }
  }
}
</script>
<style scoped lang="scss">
.example {
  padding: 25px;
  background-color: #fff;

  .title {
    text-align: center;
  }
}
</style>
